home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / C_ALGORI.ZIP / CPT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-12  |  2.2 KB  |  107 lines

  1. #ifdef CPT_H                    /* Allow compiler one copy */
  2. #else
  3. #define CPT_H
  4.  
  5.  
  6. ////////////////////////////////////////////////////////////////////////
  7. //
  8. //  Module Name:  cpt.h
  9. //
  10. //  Description:  Cpt include file for class definitions
  11. //
  12. //  Written by:   John Tal
  13. //
  14. //
  15. //  Modification history:
  16. //
  17. //  Date         Engineer     Mod #          Modification Description
  18. //
  19. //  12-Feb-1992  Tal          v 1.0-001      Initial conversion to C++
  20. //
  21. ////////////////////////////////////////////////////////////////////////
  22.  
  23. #define CPT_BUFSIZE 1024
  24. #define CPT_ASCIIBYTES  255
  25.  
  26. #define CPT_MAX_CONVOLUTIONS 16
  27.  
  28. #define CPT_ID  "CPT_KEY_FILE"
  29. #define CPT_VER  "CPT_VER_1"
  30.  
  31. #define CPT_ENCODE 0
  32. #define CPT_DECODE 1
  33. #define CPT_FILE_LEN 64
  34.  
  35. #define CPT_ID_LEN 16
  36. #define CPT_VERS_LEN 16
  37. #define CPT_KEYID_LEN 16
  38. #define CPT_KEYSTR_LEN 14
  39.  
  40. //
  41. // Cpt Class
  42. //
  43.  
  44. class CPT_C
  45. {
  46.  
  47. private:
  48.  
  49.    FILE  *KeyFile;
  50.    FILE  *InFile;
  51.    FILE  *OutFile;
  52.    CHAR  szKeyFile[CPT_FILE_LEN];
  53.    CHAR  szInFile[CPT_FILE_LEN + 1];
  54.    CHAR  szOutFile[CPT_FILE_LEN + 1];
  55.    UCHAR cCodes[CPT_DECODE + 1][CPT_MAX_CONVOLUTIONS][CPT_ASCIIBYTES + 1];
  56.    INT   iConvolutions;
  57.    CHAR  szCptId[CPT_ID_LEN + 1];
  58.    CHAR  szCptVers[CPT_VERS_LEN + 1];
  59.    CHAR  szCptKeyId[CPT_KEYID_LEN + 1];
  60.    CHAR  szKeyStr[CPT_KEYSTR_LEN + 1];
  61.    INT   iCurConvolution;
  62.    INT   iJobType;
  63.  
  64. protected:
  65.    SHORT  lpad(PCHAR,INT);
  66.    SHORT  srep(PCHAR,CHAR,CHAR);
  67.    SHORT  MemoryKeyGen(INT);
  68.    SHORT  ReverseKeys(VOID);
  69.    SHORT  CodeBuffer(UCHAR *,UCHAR *,INT);
  70.    SHORT  AdjustConvolution(VOID);
  71.  
  72. public:
  73.    CPT_C(VOID) { };
  74.    ~CPT_C(VOID) { };
  75.  
  76.    SHORT  SetJobType(INT);
  77.    SHORT  GenKeys(VOID);
  78.    SHORT  WriteKeys(VOID);
  79.    SHORT  ReadKeys(VOID);
  80.    SHORT  CodeFile(VOID);
  81.  
  82.    SHORT  OpenKeyFile(VOID);
  83.    SHORT  CloseKeyFile(VOID);
  84.  
  85.    SHORT  OpenInFile(VOID);
  86.    SHORT  CloseInFile(VOID);
  87.  
  88.    SHORT  OpenOutFile(VOID);
  89.    SHORT  CloseInFile(VOID);
  90.  
  91.    SHORT  SetKeyFileStr(PCHAR);
  92.    SHORT  SetKeyStr(PCHAR);
  93.    SHORT  SetInFile(PCHAR);
  94.    SHORT  SetOutfile(PCHAR);
  95.    SHORT  SetConvolutions(SHORT);
  96.  
  97.    SHORT  SetKeyFile(FILE *);
  98. };
  99.  
  100.  
  101. SHORT  CptUsrGetKeyData(VOID);
  102. SHORT  CptUsrCode(VOID);
  103.  
  104.  
  105. #endif
  106. #endif
  107.